﻿using Factory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Basic
{
    public interface ITimerProvider
    {
        DateTime CurrentDate { get; }
    }

    public class TimerProvider : ITimerProvider
    {
        public DateTime CurrentDate => DateTime.Now;
    }

    public class SystemTimeprovider : ITimerProvider
    {
        public DateTime CurrentDate => DateTime.Now;
    }

    

    public class ClientConstructor//客户端调用 通过构造函数实现
    {
        private ITimerProvider _timeProvider;

        public ClientConstructor(ITimerProvider timeProvider)
        {
            _timeProvider = timeProvider;
        }
    }

    public class ClientSetter//客户端调用 通过setter实现
    {
        //private ITimerProvider _timeProvider;

        public ITimerProvider Timeprovider { get; set; }
        //{
        //    get { return _timeProvider; }//getter本身和setter方式注入没有关系
        //    set { _timeProvider = value; }//setter注入
        //}

    }

}
